<?php

class Upload extends CI_Controller {
 
 function __construct()
 {
  parent::__construct();
  $this->load->helper(array('form', 'url'));
 }
 
 function index()
 { 
  $this->load->view('upload', array('error' => ' ' ));
 }

 function do_upload()
 {
  $config['upload_path'] = './uploads/';
  $config['allowed_types'] = 'gif|jpg|png';
//  $config['max_size'] = '100';
//  $config['max_width']  = '1024';
//  $config['max_height']  = '768';
  
  $this->load->library('upload', $config);
  
  $field_name = "100003";
  
  $this->load->library('tools');
  
  
 
  if ( ! $this->upload->do_upload('test'))
  {
   $error = array('error' => $this->upload->display_errors());
   
   $this->load->view('upload', $error);
  } 
  else
  {
  	
   $user = $this->input->post('user');
   $seqence = $this->input->post('seqence'); 
   $path ='./uploads/resize/'.$user.'/'.$seqence;
   
//   echo "path is ".$path;
//   echo "<br>";
//   if(!$this->checkFolderExist($path)){
	if(!$this->tools->checkFolderExist($path)){
   		$this->tools->createFolder($path);
   }
   $fileInfo=$this->upload->data();   
   $data = array('upload_data' =>$fileInfo );   
   $this->tools->resize($fileInfo['file_name'],$path.'/'.$field_name.$fileInfo['file_ext']);
   $this->load->view('upload_success', $data);
   
   }
 }

}
?>